package com.medassistent.gui;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class AlarmReceiver extends BroadcastReceiver{

	@Override
	public void onReceive(Context context, Intent intent) {
		NotificationManager mNM;
        mNM = (NotificationManager)context.getSystemService(context.NOTIFICATION_SERVICE);
        Notification notification = new Notification(R.drawable.ic_launcher, intent.getExtras().getStringArray("dados")[4] + intent.getExtras().getStringArray("dados")[2] + intent.getExtras().getStringArray("dados")[3],
        System.currentTimeMillis());
        
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        String msg = intent.getExtras().getStringArray("dados")[1];
        int id = Integer.parseInt(intent.getExtras().getStringArray("dados")[0]);
        
        notification.defaults |= Notification.DEFAULT_ALL;
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        
        
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
        notification.setLatestEventInfo(context, intent.getExtras().getStringArray("dados")[4] + intent.getExtras().getStringArray("dados")[2] + intent.getExtras().getStringArray("dados")[3], msg, contentIntent);
        
        mNM.notify(id, notification);
		
	}

}
